package com.chenye.rmi;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * @Package: [com.chenye.rmi]
 * @Description: [一句话描述该类的功能]
 * @Author: [chenye]
 * @CreateDate: [2018/3/28 9:27]
 * @UpdateUser: [chenye(如多次修改保留历史记录，增加修改记录)]
 * @UpdateDate: [2018/3/28 9:27，(如多次修改保留历史记录，增加修改记录)]
 * @UpdateRemark: [说明本次修改内容, (如多次修改保留历史记录，增加修改记录)]
 * @Version: [v1.0]
 */
public class Server extends UnicastRemoteObject implements TestService{
//    private static final long serialVersionUID = -271947229644133464L;

    public Server() throws RemoteException {
        super();
    }

    @Override
    public String say(String str) {
        return str;
    }

    @Override
    public String sayHi() {
        return "nihaoapengyou";
    }

    public static void main(String[] args) throws RemoteException {
        Server server = new Server();
        try {
            LocateRegistry.createRegistry(1099);
            Naming.rebind("rmi://172.29.33.247:1099/testService",server);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println("服务启动成功");
    }
}
